package com.supermap.business.product;

import com.alibaba.dubbo.config.annotation.Reference;
import com.supermap.dataservice.util.JSONUtil;
import com.supermap.dubbo.api.product.AgrCollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author aqua
 * @description 农情列表收藏
 * @date 2018年11月01 上午 11:45
 * @email 1301584033@qq.com
 */

@Api(value="收藏取消农情列表查询",tags="农情接口")
@Controller
@RequestMapping("/agrcollect")
public class AgrCollectController {

    @Reference(timeout = 10000)
    private AgrCollectService agrCollectService;

    /**
     *
     * 为该用户收藏农情
     * @param  userId
     * @param agrId
     * @return  JSONUtil
     */
    @ApiOperation(value="收藏农情",notes="根据用户ID和农情ID为该用户收藏该农情")
    @ApiImplicitParams({
            @ApiImplicitParam(name="userId",value="用户id",dataType="int", required = true, paramType = "query",example="1"),
            @ApiImplicitParam(name="agrId",value="农情id",dataType="int", required = true, paramType = "query",example="1")
    })
    @PutMapping("/putAgrCollect")
    @ResponseBody
    public JSONUtil putAgrCollect(Integer userId, Integer agrId){
        return  agrCollectService.putAgrCollect(userId,agrId);

    }




    /**
     *
     * 通过用户ID和农情ID查看该农情是否已被该用户收藏
     * @param  userId
     * @param agrId
     * @return  JSONUtil
     */
    @ApiOperation(value="看该农情是否已被该用户收藏" ,notes="根据用户ID和农情ID查看该用户是否收藏该农情")
    @ApiImplicitParams({
            @ApiImplicitParam(name="userId",value="用户id", required = true,dataType="int", paramType = "query"),
            @ApiImplicitParam(name="agrId",value="农情id", required = true,dataType="int", paramType = "query")
    })
    @GetMapping("/isBindUserAgrInfo")
    @ResponseBody
    public JSONUtil isBindUserAgrInfo(Integer userId, Integer agrId){
        return  agrCollectService.isBindUserAgrInfo(userId,agrId);

    }


    /**
     *
     * 通过用户ID分页查询出已经被收藏的数据
     * @param  userId
     * @param pageSize
     * @param  pageNum
     * @return  JSONUtil
     */
    @ApiOperation(value="分页查询 圈子/我的/收藏  农情列表",notes="查看圈子/我的农情/我收藏的农情" +
            "当type可以为1/2/3 type=1 查看所用农情列表 此时areaCode必传 " +
            "当type=2 查看我的所有农情  区域ID可以不传" +
            "当tyoe=3 查看我收藏的农情  区域ID可以不传")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "areaCode", value = "区域Id", required = false, dataType = "String",paramType = "path"),
            @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "String",paramType = "path"),
            @ApiImplicitParam(name = "type", value = "1/2/3", required = true, dataType = "int",paramType = "path"),
            @ApiImplicitParam(name = "pageSize", value = "当前页", required = true, dataType = "int",paramType = "path"),
            @ApiImplicitParam(name = "pageNum", value = "当前条数", required = true, dataType = "int",paramType = "path"),
    })
   @GetMapping("/getPageAgrListByUserId")
    @ResponseBody
    public JSONUtil getPageAgrListByUserId(String farmId,String areaCode,String userId, int pageSize, int pageNum,int type,String beginTime,String endTime){
        return  agrCollectService.getPageAgrListByUserId(farmId,areaCode,userId,pageSize,pageNum,type,beginTime,endTime);

    }

    /**
     *
     * 删除
     * @param  userId
     * @param agrId
     * @return  JSONUtil
     */
    @ApiOperation(value="删除已收藏的农情",notes="根据用户ID和农情ID删除已收藏的农情")
    @ApiImplicitParams({
            @ApiImplicitParam(name="userId",value="用户id", required = true,dataType="int", paramType = "query"),
            @ApiImplicitParam(name="agrId",value="农情id", required = true,dataType="int", paramType = "query")
    })
    @DeleteMapping("/delByUseIdAndAfrid")
    @ResponseBody
    public JSONUtil delByUseIdAndAfrid(Integer userId, Integer agrId) {
        return agrCollectService.delByUseIdAndAfrid(userId, agrId);

    }




}
